package com.banciyuan.wallpaper.base;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.WindowManager;

import com.baidu.mobstat.StatService;
import com.banciyuan.wallpaper.config.retrofit.RetrofitFactory;

import retrofit2.Retrofit;


/**
 * Created by squall on 2016/5/11.
 */
public class BaseActivity<T> extends FragmentActivity {

    protected Retrofit retrofit;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initNetWork();

    }

    protected void initNetWork() {
        retrofit = RetrofitFactory.creatRetrofit(getBaseContext());
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        hideStatusBar();
    }

    @Override
    protected void onResume() {
        super.onResume();
        hideStatusBar();
        StatService.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        StatService.onPause(this);
    }

    public void hideStatusBar() {
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
            int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
            getWindow().getDecorView().setSystemUiVisibility(uiOptions);
        } else {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }


    protected void OnNetWork() {

    }

    protected void OnInitArgs() {

    }

    protected void OnInitUI() {

    }

    protected void OnInitAction() {
    }

}
